package com.ebiz.jo.imageBrowser.pop
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import flash.text.TextField;
	
	public class PopItemRenderer
	{
		public var view:Sprite
		public var info:PopItem
		public var txtName:TextField;
		public var txtDescription:TextField;
		public var loaderContainer:Sprite;
		public function PopItemRenderer($view:Sprite,$info:PopItem)
		{
			super();
			this.view = $view;
			this.info = $info;
			this.distill();
			var $name:String = String(this.info.name);
			if($name){
				this.txtName.htmlText = "<b><u><a>"+$name.toUpperCase()+"</a></u></b>";
			}else{
				this.txtName.htmlText = "";
			}
			this.txtName.addEventListener(MouseEvent.MOUSE_DOWN,txtName_mouseDownHandler);
			this.txtDescription.text = this.info.description;
			//load image
			var $loader:ImageLoaderPop = new ImageLoaderPop();
			$loader.oriW = this.loaderContainer.width;
			$loader.oriH = this.loaderContainer.height;
			$loader.loadURL(this.info.image);
			this.loaderContainer.addChild($loader);
//			this.loaderContainer.visible = false;
		}
		private function distill():void{
			txtName = this.view.getChildByName("linkTxtName") as TextField;
			txtDescription = this.view.getChildByName("linkTxtDescription") as TextField;
			loaderContainer = this.view.getChildByName("linkLoader") as Sprite;
		}
		private function txtName_mouseDownHandler(event:MouseEvent):void{
			flash.net.navigateToURL(new URLRequest(this.info.link),"_blank");
		}
	}
}